<?php
	if ($this->paginator != null) {
		if (!isset($_GET['page']))
			$count	= 0;
		else
			$count	= ($_GET['page'] - 1)*$this->perpage;
?>
	<h2 style="font-weight: bold; padding-bottom: 10px;">Danh sách giáo viên</h2>
	<table class="table table-striped">
		<tr>
			<td style="width: 5%"><strong>STT</strong></td>
			<td style="width: 20%"><strong>Tên đăng nhập</strong></td>
			<td style="width: 20%"><strong>Họ tên</strong></td>
			<td style="width: 15%"><strong>Ngày sinh</strong></td>
			<td style="width: 15%"><strong>Chức vụ</strong></td>
			<td style="width: 20%"><strong>Tạo</strong></td>
			<td style="width: 5%"></td>
		</tr>
	<?php foreach ($this->paginator as $item) : $count++;?>
		<tr>
			<td><?php echo $count?></td>
			<td><?php echo $item->username;?></td>
			<td><?php echo $item->name;?></td>
			<td>
				<?php
					$parts = explode('-', $item->birthday);
					$newFormat  = $parts[2]."-".$parts[1]."-".$parts[0];
					echo $newFormat;
				?>
			</td>
			<td><?php if ($item->level == 0) echo "Giáo viên"; else echo "Quản lý";?></td>
			<td><?php echo $item->created_at;?></td>
			<td align="center">
				<?php if ($this->level == 1 && $item->level == 0) {?>
					<a href="<?php echo $this->basePath()?>/admin/deleteteacher/<?php echo $item->teacher_id?>" Onclick="return ConfirmDelete()">
						<i class="glyphicon glyphicon-trash"></i>
					</a>
				<?php }?>
			</td>
		</tr>
	<?php endforeach; ?>
	</table>
<?php
	}
	$url	= "viewteacher";
	echo $this->paginationControl(
		$this->paginator,
		'sliding',
		array('partial/admin/paginator.phtml', 'Teacher'),
		array(
			'route' => 'admin',
			'url'	=> $url,
		)
 	);